import json

from config import BASE_PATH


def read_json(fileName, apiName):
    """

    :param fileName: 文件名
    :param apiName: 指定接口的测试数据
    """
    # 获取测试数据的文件路径
    file_path = BASE_PATH + '/data/' + fileName + '.json'
    # 读取测试数据
    with open(file_path, encoding='utf8') as f:
        # 将测试数据解析为字典类型
        data = json.load(f)
    # 获取指定接口的测试数据
    api_data = data.get(apiName)
    # print(api_data)
    # 定义一个空列表
    api_data_list = list()

    # 列表嵌套字典的测试数据转换为列表嵌套元组
    for case_data in api_data:
        case_data_list = (case_data.values())
        api_data_list.append(tuple(case_data_list))

    return api_data_list

if __name__ == '__main__':
    print(read_json('test_data','img_exp_status_code'))